<!-- 模块说明 -->
<template>
  <div class="box">
    <el-table :data="list" border style="width: 100%">
      <el-table-column align="center" label="接种序号">
        <template #default="scoped">
          <p class="idP">
            <span>{{ scoped.$index+1 }}</span>
            <span v-if="scoped.row.time > nowTime" class="idS">预约</span>
          </p>
        </template>
      </el-table-column>
      <el-table-column align="center" label="用户id">
        <template #default="scoped">
          <span>{{ scoped.row.userid }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="疫苗名称">
        <template #default="scoped">
          <span>{{ scoped.row.vaname }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" label="预约时间">
        <template #default="scoped">
          <span>{{ scoped.row.time }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="接种次数">
        <template #default="scoped">
          <span>{{ scoped.row.type }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="接种地址">
        <template #default="scoped">
          <span>{{ scoped.row.place }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="联系电话">
        <template #default="scoped">
          <span>{{ scoped.row.tel }}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script lang="ts" setup>
import { getUseList } from "../../api/health";
import { useUserStore } from "../../store/user";
// import  axios  from "axios";
import { ref, onMounted } from "vue";
const { userid } = useUserStore();
const list = ref([]);
const getNowDate = () => {
  const timeOne = new Date();
  const year = timeOne.getFullYear();
  let month: any = timeOne.getMonth() + 1;
  let day: any = timeOne.getDate();
  month = month < 10 ? "0" + month : month;
  day = day < 10 ? "0" + day : day;
  const NOW_MONTHS_AGO = `${year}-${month}-${day}`;
  return NOW_MONTHS_AGO;
};
const nowTime = getNowDate();
const useList = async () => {
  let res = await getUseList({ userid });
  list.value = res.data;
  // console.log(res, "list");
};

onMounted(() => {
  useList();
});
</script>
<style scoped lang="scss">
.box {
  .idP {
    position: relative;
    .idS {
      position: absolute;
      right: 0;
      top: 0;
      padding: 2px;
      background: skyblue;
      line-height: 20px;
      text-align: center;
      border-radius: 8px;
    }
  }
}
</style>
